cmake_minimum_required(VERSION 3.10)
project(a_cplusprime)

# compile features
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

# macros
add_definitions(-DUNICODE -D_UNICODE)


message(STATUS "===CMAKE SET VALUES===:")
message(STATUS "MY_VAR = ${MY_VAR}")

# need eigen
message(STATUS "eign3:")
if (NOT EIGEN3_INCLUDE_DIR)
    if(WIN32)
        set(EIGEN3_INCLUDE_DIR "D:/sai/Eigen3")
    else()
        set(EIGEN3_INCLUDE_DIR "/usr/include/eigen3")
    endif()
endif()
message(STATUS "EIGEN3_INCLUDE_DIR = ${EIGEN3_INCLUDE_DIR}")

# opencv
message(STATUS "opencv:")
find_package(OpenCV REQUIRED )
if (OpenCV_FOUND)
    message(STATUS "OpenCV_DIR = ${OpenCV_DIR}")
endif()

# itk
find_package(ITK)
if (ITK_FOUND)
    include(${ITK_USE_FILE})
endif()
message(STATUS "ITK_DIR = ${ITK_DIR}")

# vtk
find_package(VTK)
if (NOT VTK_FOUND)
  message(STATUS "Skipping example: ${VTK_NOT_FOUND_MESSAGE}")
  return ()
endif ()
message(STATUS "VTK_DIR = ${VTK_DIR}")

# Ceres
find_package( Ceres)
set(CERES_INCLUDE_DIR "/opt/CeresSolver/include")

# Pcl
find_package(PCL)
message(STATUS "PCL_DIR = ${PCL_DIR}")

# Qt
find_package(Qt5 COMPONENTS Core)
if (Qt5_FOUND)
    message(STATUS "found Qt5: ${Qt5_DIR}")
endif()

## set ME_* variables
set(ME_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(THIRDPART_DIR "${ME_SOURCE_DIR}/thirdparty")

## include common.cmake
set(COMMON_DIR ${ME_SOURCE_DIR}/common)
include(${COMMON_DIR}/common.cmake)

## include memath.cmake
set(MEMATH_DIR ${ME_SOURCE_DIR}/memath)
include(${MEMATH_DIR}/memath.cmake)

## include algorithm.cmake
set(ALGORITHM_DIR ${ME_SOURCE_DIR}/algorithm)
include(${ALGORITHM_DIR}/algorithm.cmake)

## copy directory to bin
add_custom_target(copy_data
    COMMAND ${CMAKE_COMMAND} -E copy_directory
    ${CMAKE_SOURCE_DIR}/Data ${CMAKE_CURRENT_BINARY_DIR}/Data/
    COMMENT "Copy Data to BINARY_DIR from ${CMAKE_SOURCE_DIR}/Data"
)


#add_subdirectory(CMakeDemo)  # simple cmake demo
#add_subdirectory(singleton)  # singleton example

add_subdirectory(cplusbasic) # c++ basic
add_subdirectory(CppPrimer)  # c++ primer
add_subdirectory(AlgorithmDemo)   #  基础的算法调试

add_subdirectory(eigendemo)  # eigen
if (OpenCV_FOUND)
    add_subdirectory(CvDemo)     # opencv demo
endif()

if (Qt5_FOUND)
    add_subdirectory(QtDemo)     # qt demo
endif()

if (ITK_FOUND)
    add_subdirectory(ItkDemo)
endif()

if (VTK_FOUND)
    add_subdirectory(VtkDemo)
endif()

if (Ceres_FOUND)
    add_subdirectory(CeresDemo)
endif()

if (PCL_FOUND)
    add_subdirectory(PclDemo)
endif()

if (FALSE)
# add_subdirectory(rldemo)      # robotics libirary demo
#add_subdirectory(kdldemo)      # kdl libirary demo
add_subdirectory(MatplotlibDemo)
endif()
